package com.hq.modeapp.bean;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.tgb.lk.ahibernate.annotation.Column;
import com.tgb.lk.ahibernate.annotation.Id;
import com.tgb.lk.ahibernate.annotation.Table;
import com.tgb.lk.demo.annotation.PrimaryKey;

@Table(name = "Ad_Bean")
public class Ad_Bean {
	
	@Id
	@Column(name = "id")
	private int id; // ���,int����,��ݿ⽨��ʱ���ֶλ���Ϊ����
	
	@PrimaryKey
	@Column(name = "Ad_Bean_id", type = "INTEGER")
	private int Ad_Bean_id=-1; // ����һ������ֵ,��type = "INTEGER"�淶һ�°�.
	
	@Column(name = "title",type = "STRING")
	private String title;//标题
	@Column(name = "tag",type = "STRING")
	private String tag;
	@Column(name = "subtitle",type = "STRING")
	private String subtitle;
	@Column(name = "imgsrc",type = "STRING")
	private String imgsrc;//图片url
	
	@Column(name = "url",type = "STRING")
	private String url;//图片url
	
	public String getTitle() {
		return title;
	}



	public String getTag() {
		return tag;
	}



	public void setTag(String tag) {
		this.tag = tag;
	}



	public String getSubtitle() {
		return subtitle;
	}



	public void setSubtitle(String subtitle) {
		this.subtitle = subtitle;
	}



	public String getUrl() {
		return url;
	}



	public void setUrl(String url) {
		this.url = url;
	}



	public void setTitle(String title) {
		this.title = title;
	}

	public String getImgsrc() {
		return imgsrc;
	}



	public void setImgsrc(String imgsrc) {
		this.imgsrc = imgsrc;
	}



	public static ArrayList<Ad_Bean> parseJson(String str) {
		ArrayList<Ad_Bean> list = new ArrayList<Ad_Bean>();
		try {
			JSONObject jsonObject = new JSONObject(str);
			JSONArray jsonArray;
			jsonArray = jsonObject.getJSONArray("headline_ad");
			int n = jsonArray.length();
			for (int i = 0; i < n; i++) {
				Ad_Bean bean = new Ad_Bean();
				bean.setTitle(jsonArray.getJSONObject(i).getString("title"));
				bean.setImgsrc(jsonArray.getJSONObject(i).getString("imgsrc"));
				bean.setSubtitle(jsonArray.getJSONObject(i).getString("subtitle"));
				bean.setTag(jsonArray.getJSONObject(i).getString("tag"));
				bean.setUrl(jsonArray.getJSONObject(i).getString("url"));
				list.add(bean);
			}
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return list;

	}
}
